var data_zh = ['你知道吗', '六月', '一日', '星期一', '是', '儿童节'];
var data_en = ['do you know', 'June', 'One day', 'Monday', 'Yes', 'Children\'s day'];
var text_if = document.querySelector("#text_if");
var text_that = document.querySelector("#text_that");
var btn_if = document.querySelectorAll("#btn_if button");
var btn_that = document.querySelectorAll("#btn_that button");
var lang = 'zh';

function swap(){
	if(lang === 'zh'){
		lang = 'en'
	}else{
		lang = 'zh';
	}
	for(var i = 0; i<btn_if.length;i++){
		btn_if[i].classList.remove("btn-primary")
		btn_if[i].classList.remove("btn-light")
		btn_that[i].classList.remove("btn-primary")
		btn_that[i].classList.remove("btn-light")
	}
	switch(lang){
		case'en':
		btn_if[0].classList.add("btn-light");
		btn_if[1].classList.add("btn-primary");
		btn_that[0].classList.add("btn-light");
		btn_that[1].classList.add("btn-primary");
		break;
		case 'zh':
		btn_if[0].classList.add("btn-primary");
		btn_if[1].classList.add("btn-light");
		btn_that[0].classList.add("btn-primary");
		btn_that[1].classList.add("btn-light");
		break;
	}
}
function res(){
	for (var i in data_zh){
		if(text_if.value === data_zh[i]){
			text_that.value = data_en[i];
			if(lang === 'en'){
				swap();
			}
		}
	}
	for(var i in data_en){
		if (text_if.value === data_en[i]){
			text_that.value = data_zh[i];
			if(lang === 'zh'){
				swap();
			}
		}
	}
}